package com.ExceptionPWTest;

import java.io.FileOutputStream;
import java.io.IOException;

public class AutoCloseableDemo {
    public static void main(String[] args) {
//放在小括号里的流会自动close
        System.out.println("程序开始");
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream("./a/ss.txt");
            fos.write(65);
            System.out.println("1");
        }catch (Exception e ){
            System.out.println("异常");
        }finally {
            try {
                fos.close();
                System.out.println("2");
            } catch (IOException e) {
                e.printStackTrace();

            }
        }
        System.out.println("程序结束");
    }
}
